﻿using AntDesign;
using Blazor.Localization;
using Blazor.Pages;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;

namespace Blazor.Core;

public class SoraniFeedbackComponentBase<TComponentOptions, TResult>: FeedbackComponent<TComponentOptions, TResult>, ISoraniComponent
{
    [Inject]
    public IStringLocalizer<CommonLocalization> CommonLoc { get; set; }
    
    [Inject]
    public MessageService MessageService { get; set; }
    
    public void ShowOperateFailedMessage()
    {
        MessageService.Error(CommonLoc[CommonLocalization.Failed].ToString());
    }
    
    public void ShowOperateSuccessfullyMessage()
    {
        MessageService.Success(CommonLoc[CommonLocalization.Success].ToString());
    }
    
    public override Task OnFeedbackCancelAsync(ModalClosingEventArgs args)
    {
        OkCancelRefWithResult.CancelAsync(default!);
        return Task.CompletedTask;
    }
}